package com.woniu.new_orange.personnel_model_wu.ecxeption;

import com.woniu.new_orange.util.Result;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;



/**
 * @Program: new_orange->ValidException
 * @Description:
 * @Author: 13488
 * @Date: 2023-02-07 12:01
 * @Version： 1.0
 **/
@RestControllerAdvice
public class ValidException {
    @ExceptionHandler(BindException.class)
    public Result validExceptionHandler(BindException exception) {
        return Result.error(exception.getBindingResult().getFieldError().getDefaultMessage());
    }
}
